#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

double s[1000], n;

int main()
{
	while (cin >> n)
	{
		if (n == 0) break;

		double sum = 0;
		for (int i=0; i < n; i++)
		{
			cin >> s[i];
			sum += s[i];
		}

		double e = sum/n, neg = 0, pos = 0;

		for (int i = 0; i < n; i++)
		{
			double diff = (double) (long) ((s[i] - e) * 100.0) / 100.0;

			if (diff < 0) neg += -diff;
			else pos += diff;
		}

		printf("$%0.2f\n", max(neg, pos));
	}

	return 0;
}
